<!DOCTYPE html>
<html>

<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>车辆审核</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <link rel="stylesheet" href="/plugins/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="/plugins/adminLTE/css/AdminLTE.css">
    <link rel="stylesheet" href="/plugins/adminLTE/css/skins/_all-skins.min.css">
    <link rel="stylesheet" href="/css/style.css">


    <script src="/plugins/jQuery/jquery-2.2.3.min.js"></script>
    <script src="/plugins/bootstrap/js/bootstrap.min.js"></script>

</head>

<body class="hold-transition skin-red sidebar-mini" >
<!-- .box-body -->
<div class="box-body">

    <!-- 数据表格 -->
    <div class="table-box">

        <!--工具栏-->
        <div class="pull-left">
            <div class="form-group form-inline">
                <div class="btn-group">
                    <button type="button" class="btn btn-default" title="删除" onclick="deleteBatch()"><i class="fa fa-trash-o"></i> 删除</button>
                    <button type="button" class="btn btn-default" title="审核通过" onclick="auditStatus()"><i class="fa fa-check"></i> 审核通过</button>
                    <button type="button" class="btn btn-default" title="驳回" onclick="exam(2)"><i class="fa fa-ban"></i> 驳回</button>
                    <button type="button" class="btn btn-default" title="刷新" ><i class="fa fa-refresh"></i> 刷新</button>
                </div>
            </div>
        </div>

        <!--工具栏/-->

        <!--数据列表-->
        <table id="dataList" class="table table-bordered table-striped table-hover dataTable">
            <thead>
            <tr>
                <th class="" style="padding-right:0px">
                    <input id="selall" type="checkbox" class="icheckbox_square-blue">
                </th>
                <th class="sorting_asc">车辆ID</th>
                <th class="sorting">车辆名称</th>
                <th class="sorting">车辆标题</th>
                <th class="sorting">价格</th>
                <th class="sorting">经纬度</th>
                <th class="sorting">品牌id</th>
                <th class="sorting">车系ID</th>
                <th class="sorting">规格详情</th>
                <th class="sorting">创建时间</th>
                <th class="sorting">更新时间</th>
                <th class="sorting">状态</th>
                <th class="sorting">上牌时间</th>
                <th class="sorting">卖家Id</th>
                <th class="sorting">卖家手机号</th>
                <th class="text-center">操作</th>
            </tr>
            </thead>
            <tbody id="goods">

            </tbody>
        </table>
        <!--数据列表/-->


    </div>
    <!-- 数据表格 /-->


</div>
<!-- /.box-body -->

</body>
<script type="text/javascript">
    $(function () {
        getData();
    });

    function getData() {
        $.ajax({
            url: "/car/getCarInfo",
            type: "get",
            data: {},
            dataType: "json",
            async: false,
            success: function (result) {
                if(result.code == 200){
                    var list = result.data;
                    var info = '';
                    $(list).each(function (i,e) {
                        info +='<tr>';
                        info +='<td><input type="checkbox" name="box" value="'+e.id+'"></td>';
                        info +='<td>'+e.id+'</td>';
                        info +='<td>'+e.name+'</td>';
                        info +='<td>'+e.title+'</td>';
                        info +='<td>'+e.price+'</td>';
                        info +='<td>'+e.lenLat+'</td>';
                        info +='<td>'+e.brandId+'</td>';
                        info +='<td>'+e.carSeriesId+'</td>';
                        info +='<td>'+e.detailsId+'</td>';
                        info +='<td>'+e.createTime+'</td>';
                        info +='<td>'+e.updateTime+'</td>';
                        info +='<td>';
                        info +='<span>';
                        if(e.status == "0"){
                            info +='未审核';
                        }else if(e.status == "1"){
                            info +='审核通过';
                        }else{
                            info +='审核未通过';
                        }
                        info +='</span>';
                        info +='</td>';
                        info +='<td>'+e.upLicensePlateTime+'</td>';
                        info +='<td>'+e.sellUserId+'</td>';
                        info +='<td>'+e.sellPhone+'</td>';
                        info +='<td class="text-center">';
                        info +='<button type="button" class="btn bg-olive btn-xs" onclick="getDetails('+e.id+')">详情</button>';
                        info +='</td>';
                        info +='</tr>';
                    });
                    $("#goods").html(info);
                    //window.location.reload();
                }

            },
            error: function () {
                alert("系统异常,请联系管理员");
            }
        })

    }

    function getRank(id) {
        var name;
        $.ajax({
            url: "/itemcat/toUpdate/"+id,
            type: "post",
            data: {},
            dataType: "json",
            async: false,
            success: function (result) {
                if(result.code == 200){
                    var itemcat = result.data;
                    name = itemcat.name;
                }
            },
            error: function () {
                alert("系统异常,请联系管理员");
            }
        });
        return name;
    }

    //通过
    function auditStatus(){
        var Ids = [];
        var arr = $("input[type=checkbox]:checked");
        $(arr).each(function(i,e){
            Ids.push(e.value);
        })
        if(Ids.length <= 0){
            alert("请选择需要通过的数据");
            return;
        }

        $.ajax({
            url : "/car/updateCar",
            type : "post",
            data : {ids:Ids},
            dataType : "json",
            async : true,
            success : function(result){
                if (result) {
                    getData();
                    alert("通过成功");
                }else{
                    alert("通过失败");
                }
            },
            error :function(){
                alert("系统异常,请联系管理员");
            }
        })
    }
    function deleteBatch() {
        var ids = [];
        $("[name=box]:checked").each(function (i,e) {
            ids.push(e.value);
        });

        if(ids.length <= 0){
            alert("请选择需要删除的行");
            return;
        }

        $.ajax({
            url:"/goods/deleteBatch/"+ids,
            type : "post",
            data:{},
            dataType : "json",
            async : false,//同步
            success : function(result) {
                if(result.code == 200){
                    window.location.reload();
                }
            },
            error : function() {
                alert("系统异常,请联系管理员");
            }
        })

    }


    function getDetails(id){
        BootstrapDialog.show({
            type : BootstrapDialog.TYPE_SUCCESS,//弹出框类型 颜色
            title : '商品详情 ',//load jquery的方法
            message : $('<div></div>').load("/goods/toDetails/"+id),// restful
            // size : BootstrapDialog.SIZE_SMALL,//size为小，默认的对话框比较宽
            buttons : [ {// 设置关闭按钮
                label : '关闭',
                action : function(dialogItself) {//点击按钮方法
                    dialogItself.close();
                }
            },{
                label : '确定',
                cssClass:'btn-success',
                action : function(dialogItself) {//点击按钮方法

                }
            } ]
            // 对话框关闭时带入callback方法
        });
    }


    function getDetails2(id) {


    }
</script>
</html>